<template>
	<view class="content">
		<view class="list-container">
			<view style="height: 20px;"></view>
			<view class="clear shenhe-text border_bottom" >
				<text class="left">联系电话 </text>
				<text class="right" >{{info.phone}} </text>
			</view>
			<view class="clear shenhe-text border_bottom" >
				<text class="left">紧急联系人 </text>
				<text class="right" >{{info.linkname}} </text>
			</view>
			<view class="clear shenhe-text border_bottom" >
				<text class="left">紧急联系人电话</text>
				<text class="right" >{{info.linkphone}} </text>
			</view>
			<view class="kh-list border_bottom" >
				<view class="clear shenhe-text"  style="height: 25px;line-height: 25px;">
					<text class="left" >公司地址 </text>
				</view>
				<view class="clear shenhe-text" style="height: 25px;line-height: 25px;">
					<text >{{info.address}} </text>
				</view>
				
			</view>
		
				
			<view>
				<view class="clear shenhe-text" style="height: 40px;line-height: 40px;">
					<text class="left">身份证/驾驶证</text>
				</view>
				<view class="clear hetong-list">
					<view class="left" v-for="(item,index) in numberpic" :key="index">
						<image :src="item.url" @tap="yulan(item.url)"></image>
					</view>
					
				</view>
				<view class="clear shenhe-text"  style="height: 40px;line-height: 40px;">
					<text class="left">营业执照/工作证明</text>
				</view>
				<view class="clear hetong-list">
					<view class="left" v-for="(item,index) in business" :key="index">
						<image :src="item.url" @tap="yulan(item.url)"></image>
					</view>
				</view>
				<view class="clear shenhe-text" style="height: 40px;line-height: 40px;">
					<text class="left">其他附件</text>
				</view>
				<view class="clear hetong-list">
					<view class="left" v-for="(item,index) in otherpic" :key="index">
						<image :src="item.url" @tap="yulan(item.url)"></image>
					</view>
				</view>
				
			</view>
			<view style="height: 30px;" v-if="!isshow_btn"></view>
			<view class="clear" style="margin: 120rpx 20rpx 200rpx; " v-if="isshow_btn">
				<button class="info_btn left" @tap="bohui()">驳回申请</button>
				<button class="info_btn right" @tap="shenhe(1)">同意申请</button>
			</view>
			<view class="menban" v-show="isalert">
				<view class="gray"></view>
					<view class="menban-content" style="top:calc(50% - 200rpx);left: 10%;right: 10%;border-radius:5px ;">
						<view class="line_title " style="position: relative;text-align: center;color: #323232;font-size: 34rpx;padding-top: 10px;">
							请填写驳回原因
							<image src="../../static/img/close-icon.png" class="close-icon" @tap="isalertAction()"></image>
						</view>
						<textarea class="bohui-textarea" v-model="check_content" placeholder="请填写驳回原因" placeholder-style="font-size:30rpx"></textarea>
						<button class="big_button" style="margin: 30rpx auto;" @tap="shenhe(-1)">
							确认
						</button>
					</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	import httpPath from '@/static/js/path.js';
	import {getlogin} from '@/static/js/login.js';
	import {fmoney} from '@/static/js/login.js';
	export default {
		data() {
			return {
				isalert:false,//驳回弹出框是否弹出
				current:0,
				iconType: ['success'],
				id:"",
				info:"",
				numberpic:[],
				business:[],
				otherpic:[],
				check_content:"",//驳回原因
				isshow_btn:false,
			}
		},
		onLoad(option) {
	       this.user = getlogin();
	       if(!this.user.islogin){
	       	uni.showModal({
	       	   showCancel:false,
	       	   content:"您还没有登录，请登录"
	       	})
	       	uni.navigateTo({
	       		url:"../public/login"
	       	})
	       }
			this.id=option.id;
			this.getinfo()
			
		},
		methods: {
			//读取信息
		  getinfo(){
			// console.log(111111111111)
			uni.request({
			      url: httpPath.filePath+"api.php/index/user/look_customer",
			      method:'POST',
			      header:{'content-type':'application/x-www-form-urlencoded'},
			      data: {member_id:this.user.member_id,user_id:this.user.user_id,id:this.id},
			      success: (res) => {
			  		if(res.data.code=="200"){
						this.info=res.data.result;
						if(this.info.numberpic!=null&&this.info.numberpic!=""&&typeof(this.info.numberpic)!="undefined"){
							
							let num=this.str_array(this.info.numberpic);
							for (let i=0;i<num.length;i++) {
								this.numberpic.push({url:httpPath.filePath+"/static/upload/image/"+num[i]})
							}
						}
						
						if(this.info.business!=null&&this.info.business!=""&&typeof(this.info.business)!="undefined"){
							let num=this.str_array(this.info.business);
							for (let i=0;i<num.length;i++) {
								this.business.push({url:httpPath.filePath+"/static/upload/image/"+num[i]})
							}
							
						}
						
						if(this.info.otherpic!=null&&this.info.otherpic!=""&&typeof(this.info.otherpic)!="undefined"){
							let num=this.str_array(this.info.otherpic);
							for (let i=0;i<num.length;i++) {
								this.otherpic.push({url:httpPath.filePath+"/static/upload/image/"+num[i]})
							}
							
						}	
						 console.log(this.user.top)
						 if(this.user.user_id==this.info.user_id){
						 	if(this.info.is_check!=1){
						 		this.isshow_btn=true;
						 	}
						 }
					}
			  		// successCallback && successCallback(this.list);
			      }
			});
		  },
		  //将字符串转化成数组
		  str_array(str){
			  console.log(str)
		  	let arry=[];
			if(str==""){
				arry=[]
			}else if(str.indexOf(",")==-1){
		  		arry.push(str)
		  	}else{
		  		arry=str.split(",")
		  	}
		  	return arry;
		  },
			// 预览图片
	      yulan(img){
		    uni.previewImage({
				  urls: [img],
				  longPressActions: {
					  // itemList: ['发送给朋友', '保存图片', '收藏'],
					  success: function(data) {
						  console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
					  },
					  fail: function(err) {
						  console.log(err.errMsg);
					  }
				  }
		    });
		  },
		  bohui(){
			  this.isalert=true;
		  }
		  ,shenhe(type){//审核资料
		      let param={};
		      if(type=="-1"){
				if(this.check_content==""||this.check_content==null){
					uni.showModal({
						showCancel:false,
						content:"请输入驳回原因"
					})
					return false;
				}
				
			  }
			  param.member_id=this.user.member_id;
			  param.is_check=type;
			  param.check_content=this.check_content;
			  param.user_id=this.user.user_id;
			  param.id=this.id;
			  uni.request({
			        url: httpPath.filePath+"/api.php/index/user/customer_check/",
			        method:'POST',
			        header:{'content-type':'application/x-www-form-urlencoded'},
			        data: param,
			        success: (res) => {
			    		if(res.data.code=="200"){
							if(type==1){
								uni.showModal({
									showCancel:false,
									content:"审核已完成"
								})
							}else{
								uni.showModal({
									showCancel:false,
									content:"您已经将资料驳回了"
								})
							}
							this.isalert=false;
							uni.navigateBack()
						}else{
							uni.showModal({
								showCancel:false,
								content:res.data.message
							})
						}
			  		
			        }
			  });
			 
		  },isalertAction(){//关闭驳回弹出框
			  this.isalert=false;
		  }
		}
	}
</script>

<style>
	@import "../../colorui/main.css";
	.bohui-textarea{display: block;margin: 10px;background: #f3f3f3;padding: 5px;height: 300rpx;width: 92%;border-radius: 5px;}
	.info_btn{width: 300rpx;border-radius: 40rpx;height: 80rpx;line-height: 80rpx;font-size: 30rpx;}
	.info_btn:nth-of-type(1){border:  1px solid #1e99ff;color: #1e99ff;}
	.info_btn:nth-of-type(2){background: #1e99ff;color: #FFFFFF;}
	page{background: #fff;}
	.kh-list{padding: 10rpx 0px;}
	.shenhe-text{height: 40px;line-height: 40px;}
</style>
